﻿namespace Gengens.Disk.Entity.entity.file
{
    /// <summary>
    /// 数据信息
    /// </summary>
    public class DataInfo : BaseModel<DataInfo>
    {
        /// <summary>
        /// 虚拟目录
        /// </summary>
        public Guid FilePathId { get; set; }

        /// <summary>
        /// 资源链接
        /// </summary>
        /// <remarks>
        /// 注意，一个资源可能会有多个所有者，删除时注意检查
        /// </remarks>
        public string Url { get; set; }

        /// <summary>
        /// 资源名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 所有者Id
        /// </summary>
        public Guid UserId { get; set; }

        /// <summary>
        /// 文件大小
        /// </summary>
        public long Size { get; set; }

        /// <summary>
        /// 文件类型
        /// </summary>
        public string FileType { get; set; }

        public DataInfo(string url, string name, Guid userid)
        {
            Url = url;
            Name = name;
            UserId = userid;
            Size = new FileInfo(Url).Length;
            FileType = Path.GetExtension(Url).ToLower();
        }
    }
}
